package com.dream.service.user.config;

import com.dream.service.user.util.ConfigUtil;

import java.util.*;

/**
 * Created by kangd on 2016/4/6.
 */
public class UserConfig {
    private static final String SPLIT = ",";

    public static String DEFAULT_ICON = ConfigUtil.getPro("default_icon");
    public static Integer DEFAULT_LoginType = Integer.valueOf(ConfigUtil.getPro("default_LoginType"));
    public static Set<Integer> THIRD_PARTY_LOGING_TYPE = new HashSet<Integer>(Arrays.asList(2,4));
    public static int[] ROUTE_TYPE = {0,100};
    public static Map<String,Integer> ROUTE_MAP = new HashMap<String, Integer>();
    static {
        List<Integer> trdPtyLoginType= new ArrayList<Integer>();
        String [] third_party_login_type = ConfigUtil.getPro("third_party_login_type").split(SPLIT);
        if(third_party_login_type !=null && third_party_login_type.length>0){
            for(String a:third_party_login_type){
                trdPtyLoginType.add(Integer.valueOf(a));
            }
        }
        if(trdPtyLoginType !=null && trdPtyLoginType.size()>0){
            THIRD_PARTY_LOGING_TYPE = new HashSet<Integer>(trdPtyLoginType);
        }

//        说明：route_type值区间值为0-99，区间值用逗号分隔，
//        当route_type值为30，表示0-29走分流1，30-99走分流2
//        route_{i}_pins表示某一些pin走指定分流，i的值从1开始，多个用逗号来区分
        String routeType = ConfigUtil.getPro("route_type","");
        if(routeType.length() > 0){
            String[] routeTypes = routeType.split(SPLIT);
            ROUTE_TYPE = new int[routeTypes.length+2];
            ROUTE_TYPE[0]=0;
            ROUTE_TYPE[ROUTE_TYPE.length - 1]=100;
            for(int i = 1 ; i< ROUTE_TYPE.length; i++){
                if(i < routeTypes.length+1){
                    ROUTE_TYPE[i] = Integer.parseInt(routeTypes[i-1]);
                }
                String ipins = ConfigUtil.getPro("route_"+i+"_pins","");
                if(ipins.length() > 0){
                    String[] arr = ipins.split(SPLIT);
                    for (String s : arr){
                        ROUTE_MAP.put(s,i);
                    }
                }
            }
        }
    }


    //邮件 注册成功

    public static String userRegisterEmailFrom = ConfigUtil.getPro("USER_REGISTER_EMAIL_FROM");
    public static String userRegisterEmailSubject = ConfigUtil.getPro("USER_REGISTER_EMAIL_SUBJECT");
    public static String userRegisterEmailTitle = ConfigUtil.getPro("USER_REGISTER_EMAIL_TITLE");
    public static String userRegisterLoggingInUrl = ConfigUtil.getPro("USER_REGISTER_LOGGING_IN_URL");
    public static String userRegisterShoppingNowUrl = ConfigUtil.getPro("USER_REGISTER_SHOPPING_NOW_URL");


    //邮件 忘记密码

    public static String userForgetPWDEmailFrom = ConfigUtil.getPro("USER_FORGET_PWD_EMAIL_FROM");
    public static String userForgetPWDEmailSubject = ConfigUtil.getPro("USER_FORGET_PWD_EMAIL_SUBJECT");
    public static String userForgetPWDTitle = ConfigUtil.getPro("USER_FORGET_PWD_EMAIL_TITLE");
    public static String userForgetPWDUrlPrefix = ConfigUtil.getPro("USER_FORGET_PWD_URL_PREFIX");
    public static int UserForget_VALID_TIME = Integer.valueOf(ConfigUtil.getPro("fpwd_valid_time"));
}
